function Amount(){
	this.binded=[];
	this._=0;
	var me=this;	
	this.plus=function(it){
		if(it instanceof Amount)return this.plusAmount(it);
		else return this.plusNumber(it);
		};
	this.plusAmount=function(fvalue){
		var clc = new Calculation(this, new Amount().value(this.value() + fvalue.value()));
		clc.calculateFirst=function(){
			return clc.second.value() - fvalue.value();
			};
		clc.calculateFirst=function(){
			return clc.first.value() + fvalue.value();
			};
		var t=new It().bind(fvalue);
		t.afterChange=function() {
			clc.second.value(clc.first.value() + fvalue.value());
		    };
		return new Amount().bind(clc.second);
		};
	this.plusNumber=function(it){
		return this.plus(new Amount().value(it));
		};
	this.minus=function(it){
		if(it instanceof Amount)return this.minusAmount(it);
		else return this.minusNumber(it);
		};
	this.minusAmount=function(fvalue){
		/*var clc = new Calculation(this, new Amount().value(this.value()-fvalue.value()));
		clc.calculateFirst=function(){
			return clc.second.value()+fvalue.value();
			};
		clc.calculateSecond=function(){
			return clc.first.value()-fvalue.value();
			};
		new It().bind(fvalue).afterChange=function() {
			clc.second.value(clc.first.value()-fvalue.value());
		    };
		new It().bind(this).afterChange=function() {
			clc.first.value(clc.second.value()+fvalue.value());
		    };
		return new Amount().bind(clc.second);*/
		var retVal=new Amount().value(me.value()-fvalue.value());
		retVal.afterChange=function() {
			me.value(retVal.value()+fvalue.value());
		    };
		new It().bind(fvalue).afterChange=function() {
			retVal.value(me.value()-fvalue.value());
		    };
		return retVal;
		};
	this.minusNumber=function(it){
		return this.minus(new Amount().value(it));
		};	
	this.multiply=function(it){
		if(it instanceof Amount)return this.multiplyAmount(it);
		else return this.multiplyNumber(it);
		};
	this.multiplyAmount=function(fvalue){
		var clc = new Calculation(this, new Amount().value(this.value() * fvalue.value()));
		clc.calculateFirst=function(){
			return clc.second.value() / fvalue.value();
			};
		clc.calculateFirst=function(){
			return clc.first.value() * fvalue.value();
			};
		var t=new It().bind(fvalue);
		t.afterChange=function() {
			clc.second.value(clc.first.value() * fvalue.value());
		    };
		return new Amount().bind(clc.second);
		};
	this.multiplyNumber=function(it){
		return this.multiply(new Amount().value(it));
		};			
	this.divide=function(it){
		if(it instanceof Amount)return this.divideAmount(it);
		else return this.divideNumber(it);
		};
	this.divideAmount=function(fvalue){
		var clc = new Calculation(this, new Amount().value(this.value() / fvalue.value()));
		clc.calculateFirst=function(){
			return clc.second.value() * fvalue.value();
			};
		clc.calculateFirst=function(){
			return clc.first.value() / fvalue.value();
			};
		var t=new It().bind(fvalue);
		t.afterChange=function() {
			clc.second.value(clc.first.value() / fvalue.value());
		    };
		return new Amount().bind(clc.second);
		};
	this.divideNumber=function(it){
		return this.divide(new Amount().value(it));
		};
	this.more=function(it){
		if(it instanceof Amount)return this.moreAmount(it);
		else return this.moreNumber(it);
		};
	this.moreAmount=function(it){return new Toggle().more(this, it);};
	this.moreNumber=function(it){return this.more(new Amount().value(it));};
	this.moreOrEquals=function(it){
		if(it instanceof Amount)return this.moreOrEqualsAmount(it);
		else return this.moreOrEqualsNumber(it);
		};
	this.moreOrEqualsAmount=function(it){return new Toggle().moreOrEquals(this, it);};
	this.moreOrEqualsNumber=function(it){return this.moreOrEquals(new Amount().value(it));};
	this.less=function(it){
		if(it instanceof Amount)return this.lessAmount(it);
		else return this.lessNumber(it);
		};
	this.lessAmount=function(it){return new Toggle().less(this, it);};
	this.lessNumber=function(it){return this.less(new Amount().value(it));};
	this.lessOrEquals=function(it){
		if(it instanceof Amount)return this.lessOrEqualsAmount(it);
		else return this.lessOrEqualsNumber(it);
		};
	this.lessOrEqualsAmount=function(it){return new Toggle().lessOrEquals(this, it);};
	this.lessOrEqualsNumber=function(it){return this.lessOrEquals(new Amount().value(it));};
	this.asText=function(){
		var me=this;
		var s=new Text().value(""+me._);		
		var w=new Amount().bind(this);
		w.afterChange=function(){s.value(""+me._);};
		return s;
		};
	}
Amount.prototype=new It();